import GUtils from '@/utils'
import dayjs from 'dayjs'
/** 获取核销记录 */
export const onGetVerificationListXhr = (params) => {
  return GUtils.Ajax.get(`/third/verification/list`, { params })
}

/** 获取我的优惠券列表 */
export const onGetCouponListXhr = (params) => {
  return GUtils.Ajax.get(`/coupon/list`, { params })
}

/** 新增优惠券 */
export const onPostAddCouponXhr = (params) => {
  return GUtils.jsonAjax.post(`/coupon/create`, params)
}

/** 编辑优惠券 */
export const onPostEditCouponXhr = (params) => {
  return GUtils.jsonAjax.post(`/coupon/edit`, params)
}

/** 获取优惠券详情 */
export const onGetCouponDetailXhr = (params) => {
  return GUtils.Ajax.get(`/coupon/detail`, { params })
}

/** 删除优惠券 */
export const onPostDeleteCouponXhr = (params) => {
  return GUtils.jsonAjax.post(`/coupon/delete`, params)
}

/** 第三方优惠券列表 */
export const onGetThirdCouponListXhr = (params) => {
  return GUtils.Ajax.get(`/coupon/third/list`, { params })
}

/** 第三方优惠券新增 */
export const onPostThirdCouponAddXhr = (params) => {
  return GUtils.jsonAjax.post(`/coupon/third/create`, params)
}

/** 第三方优惠券编辑 */
export const onPostThirdCouponEditXhr = (params) => {
  return GUtils.jsonAjax.post(`/coupon/third/edit`, params)
}

/** 第三方优惠券详情 */
export const onGetThirdCouponDetailXhr = (params) => {
  return GUtils.Ajax.get(`/coupon/third/detail`, { params })
}

/** 第三方优惠券删除 */
export const onPostDeleteThirdCouponXhr = (params) => {
  return GUtils.jsonAjax.post(`/coupon/third/delete`, params)
}

/** 第三方优惠券-新增-第三方店铺ID-下拉选项 */
export const onGetThirdCouponShopListXhr = (params) => {
  return GUtils.Ajax.get(`/shop/shop/query/third/option`, { params })
}

/** 结束洗车订单 */
export const onPostEndWashOrderXhr = (params) => {
  return GUtils.jsonAjax.post(`/order/washOrder/completeOrder`, params)
}

/** 导出洗车订单 */
export const onPostExportWashOrderXhr = ({
  callback,
  errorCallback,
  ...params
}) => {
  const times = new Date().getTime()
  const key = dayjs(times).format('YYYY-MM-DD') + `_${times}`
  return GUtils.fileAjax({
    method: 'post',
    url: '/car/web/order/washOrder/export',
    data: params,
    filename: `洗车订单${key}.xlsx`,
    callback,
    errorCallback,
  })
}

/** 停车场类型 */
export const onGetPlatformTypeXhr = (params) => {
  return GUtils.jsonAjax.post(`/park/parkSystem/search`, params)
}

/** 根据停车场类型查询 商户帐号 */

export const onPostShopAccountListByPlatformTypeXhr = (params) => {
  return GUtils.jsonAjax.post('/park/parkSystemAccount/search', params)
}

/** 作废核销记录 */
export const onPostCancelVerificationXhr = (params) => {
  return GUtils.jsonAjax.post(`/third/verification/invalid`, params)
}

/** 用户优惠券列表 */
export const onGetUserCouponListXhr = (params) => {
  return GUtils.Ajax.get(`/system/user/coupon/list`, { params })
}

/** 作废用户优惠券 */
export const onPostCancelUserCouponXhr = (params) => {
  return GUtils.jsonAjax.post(`/system/user/coupon/invalid`, params)
}
